// Agent basis in project massimEcomp
/* agent perceives an area that is a square with the size 17 with
   the agent in the center. Each agent is able to see 289 cells. */

/* Initial beliefs and rules */
/* BELIEFS */


/* RULES */



/* initial DESIRES */
!search_cows.


/* INTENTIONS (PLANS AND ACTIONS) */
+!find_pos : true
	<- .wait("+pos(_,_,_)").

+!search_cows : not pos(_,_,_)
	<- !find_pos;
	   !search_cows.

+!search_cows : pos(_,_,_) & not cow(_,_,_)
  <- !move;
     !search_cows.

+!search_cows : pos(_,_,_) & cow(_,_,_)
  <- 	!goto_cow_position.

+!goto_cow_position : pos(_,_,_) & cow(_,Cx,Cy)
  <- 	+target(Cx,Cy);
     	!move.

+!move : pos(X,Y,_) & not target(_,_)
  <- .print("move random");
 //    br.poli.ecomp.sma.massim.action.RandomPos(X,Y,NewX,NewY);
 //    br.poli.ecomp.sma.massim.action.FindDirection(X,Y,NewX,NewY,Direction);
 //    moveTo(Direction);
 	moveTo(northeast);
     .wait("+pos(_,_,_)").
//     !move.

+!move : pos(X,Y,_) & target(Cx,Cy) & Cx \== X & Cy \== Y
	<- .print("move to target");
	     br.poli.ecomp.sma.massim.action.FindPos(X,Y,Cx,Cy,Direction);
	//     br.poli.ecomp.sma.massim.action.FindDirection(X,Y,NewX,NewY,Direction);
	     moveTo(Direction);
	     !move.

+!move : pos(X,Y,_) & target(Cx,Cy) & Cx == X & Cy == Y
  <- .print("target end");
     -target(Cx,Cy);
     !search_cows.

